const mongoose = require('mongoose');

// 学习步骤模式
const stepSchema = new mongoose.Schema({
  title: {
    type: String,
    required: true
  },
  description: {
    type: String
  },
  cardId: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'Card'
  },
  exerciseId: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'Exercise'
  },
  order: {
    type: Number,
    required: true
  },
  estimatedTime: {
    type: Number, // 预计完成时间（分钟）
    default: 10
  }
});

// 学习阶段模式
const stageSchema = new mongoose.Schema({
  title: {
    type: String,
    required: true
  },
  description: {
    type: String
  },
  order: {
    type: Number,
    required: true
  },
  steps: [stepSchema]
});

// 学习路径模式
const learningPathSchema = new mongoose.Schema({
  title: {
    type: String,
    required: true
  },
  description: {
    type: String
  },
  documentId: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'Document',
    required: true
  },
  createdBy: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'User'
  },
  isAutoGenerated: {
    type: Boolean,
    default: true
  },
  stages: [stageSchema],
  createdAt: {
    type: Date,
    default: Date.now
  },
  updatedAt: {
    type: Date,
    default: Date.now
  }
});

const LearningPath = mongoose.model('LearningPath', learningPathSchema);

module.exports = LearningPath; 